const fs=require('fs')
const path=require('path')
function news() {
    let filepath = path.join(__dirname, './data/news.json')
    let str = fs.readFileSync(filepath, 'utf-8')
    return JSON.parse(str)
}
function students() {
    let filepath = path.join(__dirname, './data/info.json')
    let str = fs.readFileSync(filepath, 'utf-8')
    return JSON.parse(str)
}
function lucystar() {
  let list=  students()
    let index = (Math.floor(Math.random() * list.length))  
    list[index].count++
    let filepath = path.join(__dirname, './data/info.json')
    fs.writeFileSync(filepath, JSON.stringify(list))
    return list[index]
}
module.exports = {
    news,
    students,
    lucystar
}